﻿using System;
using WPT = WorkNodeFramework.WorkNodePropertiesTable;

namespace WorkNodeFramework
{
    public class WorkNodeProperties:WorkNodeProperties<WorkNodeProperties>
    { 
    }

    public abstract class WorkNodeProperties<T>:FieldSet<T>
        where T:WorkNodeProperties<T>
    {
        /// <summary>
        /// Gets the ID of WorkNode
        /// </summary>
        public Guid WorkNodeID { 
            get {
                return (Guid)this[WPT.WorkNodeIDColumnName];
            }
            set {
                this[WPT.WorkNodeIDColumnName] = value;
            }
        }
        /// <summary>
        /// Gets or sets name of property
        /// </summary>
        public string Name {
            get {
                return (string)this[WPT.NameColumnName];
            }
            set {
                this[WPT.NameColumnName] = value;
            }
        }
        /// <summary>
        /// Gets or sets content of property
        /// </summary>
        public string Content {
            get {
                return (string)this[WPT.ContentColumnName];
            }
            set {
                this[WPT.ContentColumnName] = value;
            }
        }

        /// <summary>
        /// Gets open date of Properties
        /// </summary>
        public DateTime OpenDate
        {
            get
            {
                if (IsNew)
                    return DateTime.Now;
                return (DateTime)base[WPT.OpenDateColumnName];
            }
            set
            {
                base[WPT.OpenDateColumnName] = value;
            }
        }

        /// <summary>
        /// Gets or sets last modified date of Properties
        /// </summary>
        public DateTime? LastDate
        {
            get
            {
                return (DateTime?)base[WPT.LastDateColumnName];
            }
            set
            {
                base[WPT.LastDateColumnName] = value;
            }
        }
    }
}